@ Note: local IDs shared with scripts.inc for LilycoveCity_ContestLobby
.set LOCALID_MAN, 3
.set LOCALID_BOY, 9
.set LOCALID_TWIN, 10
.set LOCALID_POKEFAN_F, 15
.set LOCALID_EXPERT_M, 16
.set LOCALID_GIRL, 17

.set NUM_OPPONENTS, VAR_0x8009

BerryBlender_Text_WantToMakePokeblocks::
   .string "哦？你是不是和这个老前辈\n想做点能量方块？$"

BerryBlender_Text_Excellent::
   .string "非常好！$"

BerryBlender_Text_MadeOldTimerSad::
   .string "哦…\n你让这个老前辈很难过…$"

BerryBlender_Text_KnowHowToMakePokeblocks::
   .string "你知道怎么做能量方块？$"

BerryBlender_Text_LetsBerryBlender::
   .string "那么让我们开始吧！\p让我们混合树果！$"

BerryBlender_Text_ExplainBerryBlending::
   .string "好吧，那么小小解释一下。\p噢，别担心，很简单的。\p当那个混合机的箭头到达\n你的标志时，就按下A键。\p这就是你要做的。\n当你自己试的时候就知道有多简单了。$"

BerryBlender_Text_DontHaveAnyBerries::
   .string "哦？\n你没有树果？\p如果你没有树果，\n你就不能做任何能量方块。$"

BerryBlender_Text_CanHaveOneOfMyBerries::
   .string "好吧，那个什么都做不了，是吧。\p你可以用我的树果，\n如果不介意我剩下的话。\p这样的话，我们就可以一起用\n树果混合机做一些能量方块。$"

BerryBlender_Text_DontHaveAnyBerriesToSpare::
   .string "如果我还有一些树果留下的话，\n我很乐意给你一个…\p可是，今天我一个多余的都没有。\n我们得以后再做了。$"

BerryBlender_Text_PokeblockCaseIsFull::
   .string "可是你的能量方块盒满了。\p你应该用掉些能量方块\n再来见我。$"

BerryBlender_Text_DontHavePokeblockCase::
   .string "可是你都没有能量方块盒。\p你应该先有一个能量方块盒，\n然后再来见我。$"

BerryBlender_Text_LetsGetBlendingAlready::
   .string "让我们混合吧！$"

BerryBlender_Text_WhatKindOfPokeblockWillIGet::
   .string "我想知道会得到什么样的能量块。\n真是让人激动！$"

BerryBlender_Text_WantToBlendPokeblocksWithUs::
   .string "你好啊！\n你是想和我们混合一些树果？$"

BerryBlender_Text_Okay::
   .string "好啊！$"

BerryBlender_Text_ThatsTooBad::
   .string "真是太糟糕了…\p不过我们总是在这附近，\n无论什么时候你都可以找我们混合！$"

BerryBlender_Text_KnowHowToMakePokeblocks2::
   .string "你一定知道如何\n混合树果的是吧？$"

BerryBlender_Text_LetsBerryBlender2::
   .string "那么让我们开始吧！\p让我们树果混合机！$"

BerryBlender_Text_ExplainBerryBlending2::
   .string "好的！\n让我解释给你听！\p当混合机的箭头转\n到你的标志时，\l就按下A键。\p就是这样。\n很简单吧，你说呢？$"

BerryBlender_Text_DontHaveAnyBerries2::
   .string "哦，但是等一下…\n你都没有树果。\p要是没有树果的话，\n你可做不了能量方块…\p我们一直在这附近，只要你有\n树果就可以找我们混合。$"

BerryBlender_Text_PokeblockCaseIsFull2::
   .string "哦，但是等一下…\n你的能量方块盒满了。\p你应该用掉一些\n能量方块再回来。$"

BerryBlender_Text_DontHavePokeblockCase2::
   .string "哦，但是等一下…\n可是你都没有能量方块盒。\p你应该先有一个能量方块盒\n然后再回来。$"

@ Unused
BerryBlender_Text_MakePokeblocksWithOurGroup::
   .string "喔，你好！你想和我们小组\n一起做能量方块吗？$"

BerryBlender_Text_OhDear::
   .string "哦，天哪！$"

BerryBlender_Text_LeftUsInShock::
   .string "哦，天哪…\p你真让我们震惊！$"

BerryBlender_Text_KnowHowToMakePokeblocks3::
   .string "你应该知道怎么做\n能量方块的吧？$"

BerryBlender_Text_LetsBerryBlender3::
   .string "哦，天哪！\n那么让我们开始吧！\p让我们树果混合机！$"

BerryBlender_Text_ExplainBerryBlending3::
   .string "哦，天哪！\p那么我会好好地解释给你听。\p当混合机的箭头转\n到你的标志时，就按下A键。\p就是这样。\n很简单吧？$"

BerryBlender_Text_DontHaveAnyBerries3::
   .string "你没有树果，\n是吗？\p要是没有树果的话，\n你可做不了能量方块。\p我们会一直在这里做能量方块，\n所以当你有树果时\l我们一起做一些吧。$"

BerryBlender_Text_PokeblockCaseIsFull3::
   .string "看起来你的能量方块盒\n满了。\p你应该用掉一些\n能量方块再回来。$"

BerryBlender_Text_DontHavePokeblockCase3::
   .string "看起来你都没有\n能量方块盒。\p你应该先有一个能量方块盒然后\n再回来。$"

BerryBlender_Text_SetNewBlenderRecord::
   .string "好吧！今天将是\n我创造新的混合机速度的记录！$"

BerryBlender_Text_LookGoodAtBlendingJoinUs::
   .string "哦，天哪！\n你好像很在行混合。\l愿意加入我们吗？？$"

BerryBlender_Text_MakeDeliciousPokeblocks::
   .string "我将做美味的能量方块\n让我的宝可梦变得更加可爱。$"

BerryBlender_Text_SaveGameBeforeBerryBlenderLink::
   .string "将会和你的朋友一起把树果\n放入树果混合机中做出能量方块。\p要不要先记录然后\n再和你的朋友连线？$"

BerryBlender_Text_SearchingForFriends::
   .string "搜索你的朋友中…\n… … B键：取消$"

BerryBlender_Text_Player1Arrived::
   .string "{STR_VAR_1}到达。$"

BerryBlender_Text_Player1And2Arrived::
   .string "{STR_VAR_1}和{STR_VAR_2}到达。$"

BerryBlender_Text_AllPlayersArrived::
   .string "{STR_VAR_1}，{STR_VAR_2}，和\n{STR_VAR_3}到达。$"

BerryBlender_Text_NoBerriesLink::
   .string "你没有树果。\n不能用树果混合机。$"

BerryBlender_Text_PokeblockCaseIsFullLink::
   .string "你的能量方块盒满了。\n不能用树果混合机。$"

BerryBlender_Text_DontHavePokeblockCaseLink::
   .string "你没有能量方块盒。\n不能用树果混合机。$"

BerryBlender_Text_LoveMakingPokeblocks::
   .string "我爱上做能量方块了。\p我总是在身上带着一些树果。$"

BerryBlender_Text_MakePokeblocksUsingBerryBlender::
   .string "如果你喜欢的话，\n我们可以一起用树果混合机\l做一些能量方块。$"

BerryBlender_Text_DontHaveAnyBerriesHaveOne::
   .string "哦？\n你还没有树果？\p那就什么都做不了。\p如果你不介意我剩下的，你可以\n从我这里选一个树果。$"

BerryBlender_Text_UseItToMakePokeblocksTogether::
   .string "我们一起用树果混合机\n加上它做能量方块。$"

BerryBlender_Text_DontHaveAnyBerriesNoneToSpare::
   .string "哦？\n你没有树果？\p如果我还有一些留下的话，\n我很乐意给你一个…\p可是，今天我一个多余的都没有。\n不好意思。$"

BerryBlender_EventScript_BerryBlender1::
	lockall
	goto_if_unset FLAG_HIDE_LILYCOVE_CONTEST_HALL_BLEND_MASTER, BerryBlender_EventScript_BlendMasterPresent
	setvar NUM_OPPONENTS, 1
	applymovement LOCALID_EXPERT_M, BerryBlender_Movement_BlendLeaderWalkInPlace
	waitmovement 0
	msgbox BerryBlender_Text_WantToMakePokeblocks, MSGBOX_YESNO
	compare VAR_RESULT, YES
	goto_if_eq BerryBlender_EventScript_TryUseBerryBlender1
	goto BerryBlender_EventScript_DeclineBlender1
	end

BerryBlender_EventScript_DeclineBlender1:
	msgbox BerryBlender_Text_MadeOldTimerSad, MSGBOX_DEFAULT
	releaseall
	end

BerryBlender_EventScript_Blender1NoBerries:
	msgbox BerryBlender_Text_DontHaveAnyBerries, MSGBOX_DEFAULT
	dotimebasedevents
	goto_if_set FLAG_DAILY_CONTEST_LOBBY_RECEIVED_BERRY, BerryBlender_EventScript_Blender1NoSpareBerries
	goto BerryBlender_EventScript_Blender1GiveSpareBerry
	end

BerryBlender_EventScript_Blender1NoSpareBerries:
	msgbox BerryBlender_Text_DontHaveAnyBerriesToSpare, MSGBOX_DEFAULT
	releaseall
	end

BerryBlender_EventScript_Blender1GiveSpareBerry:
	msgbox BerryBlender_Text_CanHaveOneOfMyBerries, MSGBOX_DEFAULT
	giveitem ITEM_PECHA_BERRY
	setflag FLAG_DAILY_CONTEST_LOBBY_RECEIVED_BERRY
	goto BerryBlender_EventScript_UseBerryBlender1
	end

BerryBlender_EventScript_UseBerryBlender1:
	msgbox BerryBlender_Text_KnowHowToMakePokeblocks, MSGBOX_YESNO
	compare VAR_RESULT, YES
	goto_if_eq BerryBlender_EventScript_StartBlender1
	goto BerryBlender_EventScript_ExplainBlending1
	end

BerryBlender_EventScript_StartBlender1:
	msgbox BerryBlender_Text_LetsBerryBlender, MSGBOX_DEFAULT
	goto BerryBlender_EventScript_DoBerryBlending
	end

BerryBlender_EventScript_ExplainBlending1:
	msgbox BerryBlender_Text_ExplainBerryBlending, MSGBOX_DEFAULT
	goto BerryBlender_EventScript_StartBlender1
	end

BerryBlender_EventScript_TryUseBerryBlender1:
	checkitem ITEM_POKEBLOCK_CASE, 1
	compare VAR_RESULT, FALSE
	goto_if_eq BerryBlender_EventScript_Blender1NoCase
	specialvar VAR_RESULT, GetFirstFreePokeblockSlot
	compare VAR_RESULT, 65535
	goto_if_eq BerryBlender_EventScript_Blender1CaseFull
	specialvar VAR_RESULT, PlayerHasBerries
	compare VAR_RESULT, FALSE
	goto_if_eq BerryBlender_EventScript_Blender1NoBerries
	msgbox BerryBlender_Text_Excellent, MSGBOX_DEFAULT
	goto BerryBlender_EventScript_UseBerryBlender1
	end

BerryBlender_EventScript_DoBerryBlending:
	copyvar VAR_0x8004, NUM_OPPONENTS
	fadescreen FADE_TO_BLACK
	special DoBerryBlending
	waitstate
	releaseall
	end

BerryBlender_EventScript_Blender1CaseFull:
	msgbox BerryBlender_Text_PokeblockCaseIsFull, MSGBOX_DEFAULT
	releaseall
	end

BerryBlender_EventScript_Blender1NoCase:
	msgbox BerryBlender_Text_DontHavePokeblockCase, MSGBOX_DEFAULT
	releaseall
	end

BerryBlender_EventScript_BerryBlender2::
	lockall
	setvar NUM_OPPONENTS, 2
	applymovement LOCALID_TWIN, Common_Movement_FaceOriginalDirection
	applymovement LOCALID_MAN, BerryBlender_Movement_BlendLeaderWalkInPlace
	waitmovement 0
	msgbox BerryBlender_Text_WantToBlendPokeblocksWithUs, MSGBOX_YESNO
	compare VAR_RESULT, YES
	goto_if_eq BerryBlender_EventScript_TryUseBerryBlender2
	goto BerryBlender_EventScript_DeclineBlender2
	end

BerryBlender_EventScript_DeclineBlender2:
	msgbox BerryBlender_Text_ThatsTooBad, MSGBOX_DEFAULT
	releaseall
	end

BerryBlender_EventScript_Blender2NoBerries:
	msgbox BerryBlender_Text_DontHaveAnyBerries2, MSGBOX_DEFAULT
	release
	end

BerryBlender_EventScript_UseBerryBlender2:
	msgbox BerryBlender_Text_KnowHowToMakePokeblocks2, MSGBOX_YESNO
	compare VAR_RESULT, YES
	goto_if_eq BerryBlender_EventScript_StartBlender2
	goto BerryBlender_EventScript_ExplainBlending2
	end

BerryBlender_EventScript_StartBlender2:
	msgbox BerryBlender_Text_LetsBerryBlender2, MSGBOX_DEFAULT
	goto BerryBlender_EventScript_DoBerryBlending
	end

BerryBlender_EventScript_ExplainBlending2:
	msgbox BerryBlender_Text_ExplainBerryBlending2, MSGBOX_DEFAULT
	goto BerryBlender_EventScript_StartBlender2
	end

BerryBlender_EventScript_TryUseBerryBlender2:
	specialvar VAR_RESULT, PlayerHasBerries
	compare VAR_RESULT, FALSE
	goto_if_eq BerryBlender_EventScript_Blender2NoBerries
	checkitem ITEM_POKEBLOCK_CASE, 1
	compare VAR_RESULT, FALSE
	goto_if_eq BerryBlender_EventScript_Blender2NoCase
	msgbox BerryBlender_Text_Okay, MSGBOX_DEFAULT
	specialvar VAR_RESULT, GetFirstFreePokeblockSlot
	compare VAR_RESULT, 65535
	goto_if_ne BerryBlender_EventScript_UseBerryBlender2
	compare VAR_RESULT, 65535
	goto_if_eq BerryBlender_EventScript_Blender2CaseFull
	end

BerryBlender_EventScript_Blender2CaseFull:
	msgbox BerryBlender_Text_PokeblockCaseIsFull2, MSGBOX_DEFAULT
	releaseall
	end

BerryBlender_EventScript_Blender2NoCase:
	msgbox BerryBlender_Text_DontHavePokeblockCase2, MSGBOX_DEFAULT
	releaseall
	end

BerryBlender_EventScript_BerryBlender3::
	lockall
	setvar VAR_0x8008, LOCALID_POKEFAN_F
	setvar NUM_OPPONENTS, 3
	applymovement LOCALID_BOY, Common_Movement_FaceOriginalDirection
	applymovement LOCALID_GIRL, Common_Movement_FaceOriginalDirection
	applymovement VAR_0x8008, BerryBlender_Movement_BlendLeaderWalkInPlace
	waitmovement 0
	msgbox BerryBlender_Text_LookGoodAtBlendingJoinUs, MSGBOX_YESNO
	compare VAR_RESULT, YES
	goto_if_eq BerryBlender_EventScript_TryUseBlender3
	goto BerryBlender_EventScript_DeclineBlender3
	end

BerryBlender_EventScript_DeclineBlender3:
	msgbox BerryBlender_Text_LeftUsInShock, MSGBOX_DEFAULT
	releaseall
	end

BerryBlender_EventScript_Blender3NoBerries:
	msgbox BerryBlender_Text_DontHaveAnyBerries3, MSGBOX_DEFAULT
	release
	end

BerryBlender_EventScript_UseBerryBlender3:
	msgbox BerryBlender_Text_KnowHowToMakePokeblocks3, MSGBOX_YESNO
	compare VAR_RESULT, YES
	goto_if_eq BerryBlender_EventScript_StartBlender3
	goto BerryBlender_EventScript_ExplainBlending3
	end

BerryBlender_EventScript_StartBlender3:
	msgbox BerryBlender_Text_LetsBerryBlender3, MSGBOX_DEFAULT
	goto BerryBlender_EventScript_DoBerryBlending
	end

BerryBlender_EventScript_ExplainBlending3:
	msgbox BerryBlender_Text_ExplainBerryBlending3, MSGBOX_DEFAULT
	goto BerryBlender_EventScript_StartBlender3
	end

BerryBlender_EventScript_TryUseBlender3:
	specialvar VAR_RESULT, PlayerHasBerries
	compare VAR_RESULT, FALSE
	goto_if_eq BerryBlender_EventScript_Blender3NoBerries
	checkitem ITEM_POKEBLOCK_CASE, 1
	compare VAR_RESULT, FALSE
	goto_if_eq BerryBlender_EventScript_Blender3NoCase
	msgbox BerryBlender_Text_OhDear, MSGBOX_DEFAULT
	specialvar VAR_RESULT, GetFirstFreePokeblockSlot
	compare VAR_RESULT, 65535
	goto_if_ne BerryBlender_EventScript_UseBerryBlender3
	compare VAR_RESULT, 65535
	goto_if_eq BerryBlender_EventScript_Blender3CaseFull
	end

BerryBlender_EventScript_Blender3CaseFull:
	msgbox BerryBlender_Text_PokeblockCaseIsFull3, MSGBOX_DEFAULT
	releaseall
	end

BerryBlender_EventScript_Blender3NoCase:
	msgbox BerryBlender_Text_DontHavePokeblockCase3, MSGBOX_DEFAULT
	releaseall
	end

BerryBlender_EventScript_BlendMasterPresent:
	lockall
	setvar NUM_OPPONENTS, 1
	msgbox BerryBlender_Text_SeeMyMasteryInAction, MSGBOX_YESNO
	compare VAR_RESULT, YES
	goto_if_eq BerryBlender_EventScript_TryBlendWithBlendMaster
	msgbox BerryBlender_Text_TooBusyNowIsee, MSGBOX_DEFAULT
	releaseall
	end

BerryBlender_EventScript_BlendMasterNoBerries:
	msgbox BerryBlender_Text_BlendMasterNoBerries, MSGBOX_DEFAULT
	releaseall
	end

BerryBlender_EventScript_TryBlendWithBlendMaster:
	checkitem ITEM_POKEBLOCK_CASE, 1
	compare VAR_RESULT, FALSE
	goto_if_eq BerryBlender_EventScript_BlendMasterNoCase
	specialvar VAR_RESULT, PlayerHasBerries
	compare VAR_RESULT, FALSE
	goto_if_eq BerryBlender_EventScript_BlendMasterNoBerries
	specialvar VAR_RESULT, GetFirstFreePokeblockSlot
	compare VAR_RESULT, 65535
	goto_if_ne BerryBlender_EventScript_BlendWithBlendMaster
	compare VAR_RESULT, 65535
	goto_if_eq BerryBlender_EventScript_BlendMasterCaseFull
	end

BerryBlender_EventScript_BlendWithBlendMaster:
	msgbox BerryBlender_Text_BlendMasterKnowHowToMakePokeblocks, MSGBOX_YESNO
	compare VAR_RESULT, NO
	call_if_eq BerryBlender_EventScript_BlendMasterExplainBlending
	msgbox BerryBlender_Text_BlendMasterLetsBerryBlender, MSGBOX_DEFAULT
	goto BerryBlender_EventScript_DoBerryBlending
	end

BerryBlender_EventScript_BlendMasterExplainBlending:
	msgbox BerryBlender_Text_BlendMasterExplainBerryBlending, MSGBOX_DEFAULT
	return

BerryBlender_EventScript_BlendMasterNoCase:
	msgbox BerryBlender_Text_BlendMasterNoPokeblockCase, MSGBOX_DEFAULT
	releaseall
	end

BerryBlender_EventScript_BlendMasterCaseFull:
	msgbox BerryBlender_Text_BlendMasterPokeblockCaseFull, MSGBOX_DEFAULT
	releaseall
	end

BerryBlender_EventScript_Blender2Man::
	msgbox BerryBlender_Text_SetNewBlenderRecord, MSGBOX_NPC
	end

BerryBlender_EventScript_Blender3PokefanF::
	msgbox BerryBlender_Text_LookGoodAtBlendingJoinUs, MSGBOX_NPC
	end

BerryBlender_EventScript_Blender2Twin::
	msgbox BerryBlender_Text_MakeDeliciousPokeblocks, MSGBOX_NPC
	end

BerryBlender_EventScript_Blender1ExpertM::
	setvar VAR_0x8008, 15
	goto BerryBlender_EventScript_ExpertMCheckGiveBerry
	end

BerryBlender_EventScript_ExpertMCheckGiveBerry:
	lock
	faceplayer
	msgbox BerryBlender_Text_LoveMakingPokeblocks, MSGBOX_DEFAULT
	specialvar VAR_RESULT, PlayerHasBerries
	compare VAR_RESULT, TRUE
	goto_if_eq BerryBlender_EventScript_ExpertMPlayerHasBerries
	compare VAR_RESULT, FALSE
	goto_if_eq BerryBlender_EventScript_ExpertMNoBerries
	end

BerryBlender_EventScript_ExpertMPlayerHasBerries:
	msgbox BerryBlender_Text_MakePokeblocksUsingBerryBlender, MSGBOX_DEFAULT
	release
	end

BerryBlender_EventScript_ExpertMNoBerries:
	checkitem ITEM_POKEBLOCK_CASE, 1
	compare VAR_RESULT, FALSE
	goto_if_eq BerryBlender_EventScript_ExpertMNoSpareBerries
	specialvar VAR_RESULT, GetFirstFreePokeblockSlot
	compare VAR_RESULT, 65535
	goto_if_eq BerryBlender_EventScript_ExpertMNoSpareBerries
	dotimebasedevents
	goto_if_set FLAG_DAILY_CONTEST_LOBBY_RECEIVED_BERRY, BerryBlender_EventScript_ExpertMNoSpareBerries
	goto BerryBlender_EventScript_ExpertMGiveBerry
	end

BerryBlender_EventScript_ExpertMNoSpareBerries:
	msgbox BerryBlender_Text_DontHaveAnyBerriesNoneToSpare, MSGBOX_DEFAULT
	release
	end

BerryBlender_EventScript_ExpertMGiveBerry:
	msgbox BerryBlender_Text_DontHaveAnyBerriesHaveOne, MSGBOX_DEFAULT
	giveitem ITEM_PECHA_BERRY
	setflag FLAG_DAILY_CONTEST_LOBBY_RECEIVED_BERRY
	msgbox BerryBlender_Text_UseItToMakePokeblocksTogether, MSGBOX_DEFAULT
	release
	end

BerryBlender_Movement_BlendLeaderWalkInPlace:
	walk_in_place_fastest_right
	step_end

BerryBlender_EventScript_BerryBlenderLink::
	lockall
	specialvar VAR_RESULT, PlayerHasBerries
	compare VAR_RESULT, FALSE
	goto_if_eq BerryBlender_EventScript_LinkBlenderNoBerries
	checkitem ITEM_POKEBLOCK_CASE, 1
	compare VAR_RESULT, FALSE
	goto_if_eq BerryBlender_EventScript_LinkBlenderNoCase
	specialvar VAR_RESULT, GetFirstFreePokeblockSlot
	compare VAR_RESULT, 65535
	goto_if_ne BerryBlender_EventScript_LinkBlenderSaveGame
	compare VAR_RESULT, 65535
	goto_if_eq BerryBlender_EventScript_LinkBlenderCaseFull
	end

BerryBlender_EventScript_LinkBlenderSaveGame:
	msgbox BerryBlender_Text_SaveGameBeforeBerryBlenderLink, MSGBOX_YESNO
	compare VAR_RESULT, YES
	goto_if_eq BerryBlender_EventScript_TryDoLinkBlender
	compare VAR_RESULT, NO
	goto_if_eq BerryBlender_EventScript_CancelLinkBlender
	end

BerryBlender_EventScript_LinkBlenderNoBerries:
	msgbox BerryBlender_Text_NoBerriesLink, MSGBOX_DEFAULT
	releaseall
	end

BerryBlender_EventScript_TryDoLinkBlender:
	call Common_EventScript_SaveGame
	compare VAR_RESULT, FALSE
	goto_if_eq BerryBlender_EventScript_CancelLinkBlender
	specialvar VAR_RESULT, IsWirelessAdapterConnected
	compare VAR_RESULT, TRUE
	goto_if_eq BerryBlender_EventScript_StartDecideLinkLeader
	message BerryBlender_Text_SearchingForFriends
	waitmessage
	special TryBerryBlenderLinkup
	waitstate
	compare VAR_RESULT, LINKUP_SUCCESS
	goto_if_eq BerryBlender_EventScript_SpawnLinkPartners
	compare VAR_RESULT, LINKUP_SOMEONE_NOT_READY
	goto_if_eq BerryBlender_EventScript_CloseLinkNotReady
	compare VAR_RESULT, LINKUP_DIFF_SELECTIONS
	goto_if_eq BerryBlender_EventScript_CloseLinkDifferentSelections
	compare VAR_RESULT, LINKUP_FAILED
	goto_if_eq BerryBlender_EventScript_CloseLink
	compare VAR_RESULT, LINKUP_CONNECTION_ERROR
	goto_if_eq BerryBlender_EventScript_LinkError
	end

BerryBlender_EventScript_TwoPlayerLink:
	msgbox BerryBlender_Text_Player1Arrived, MSGBOX_DEFAULT
	goto BerryBlender_EventScript_DoLinkBerryBlending
	end

BerryBlender_EventScript_ThreePlayerLink:
	msgbox BerryBlender_Text_Player1And2Arrived, MSGBOX_DEFAULT
	goto BerryBlender_EventScript_DoLinkBerryBlending
	end

BerryBlender_EventScript_FourPlayerLink:
	msgbox BerryBlender_Text_AllPlayersArrived, MSGBOX_DEFAULT
	goto BerryBlender_EventScript_DoLinkBerryBlending
	end

BerryBlender_EventScript_DoLinkBerryBlending:
	setvar VAR_0x8004, 0  @ number of opponents, 0 indicates Link
	fadescreen FADE_TO_BLACK
	removeobject 240 @ Unclear where these local IDs come from,
	removeobject 239 @ but presumably they'd be the 4 link players
	removeobject 238
	removeobject 237
	special DoBerryBlending
	waitstate
	releaseall
	end

BerryBlender_EventScript_CancelLinkBlender:
	releaseall
	end

BerryBlender_EventScript_LinkBlenderCaseFull:
	msgbox BerryBlender_Text_PokeblockCaseIsFullLink, MSGBOX_DEFAULT
	releaseall
	end

BerryBlender_EventScript_LinkBlenderNoCase:
	msgbox BerryBlender_Text_DontHavePokeblockCaseLink, MSGBOX_DEFAULT
	releaseall
	end

BerryBlender_EventScript_CloseLinkNotReady:
	special CloseLink
	msgbox Text_SomeoneIsNotReadyToLink, MSGBOX_DEFAULT
	releaseall
	end

BerryBlender_EventScript_CloseLinkDifferentSelections:
	special CloseLink
	msgbox Text_PlayersMadeDifferentSelections, MSGBOX_DEFAULT
	releaseall
	end

BerryBlender_EventScript_CloseLink:
	special CloseLink
	msgbox gText_PokeblockLinkCanceled, MSGBOX_DEFAULT
	releaseall
	end

BerryBlender_EventScript_LinkError:
	special CloseLink
	msgbox Text_LinkErrorPleaseReset, MSGBOX_DEFAULT
	releaseall
	end

BerryBlender_EventScript_SpawnLinkPartners:
	fadescreen FADE_TO_BLACK
	specialvar VAR_RESULT, GetLinkPartnerNames
	copyvar VAR_0x8008, VAR_RESULT
	copyvar VAR_0x8004, VAR_0x8008
	special SpawnLinkPartnerObjectEvent
	goto BerryBlender_EventScript_LinkPlayersArrived
	end

BerryBlender_EventScript_LinkPlayersArrived:
	fadescreen FADE_FROM_BLACK
	switch VAR_0x8008
	case 2, BerryBlender_EventScript_TwoPlayerLink
	case 3, BerryBlender_EventScript_ThreePlayerLink
	case 4, BerryBlender_EventScript_FourPlayerLink
	end

BerryBlender_EventScript_StartDecideLinkLeader:
	setvar VAR_0x8004, LINK_GROUP_BERRY_BLENDER
	goto BerryBlender_EventScript_DecideLinkLeader
	end

BerryBlender_EventScript_DecideLinkLeader:
	message LilycoveCity_ContestLobby_Text_PleaseDecideLinkLeader
	waitmessage
	multichoice 16, 6, MULTI_LINK_LEADER, FALSE
	switch VAR_RESULT
	case 0, BerryBlender_EventScript_TryJoinGroup
	case 1, BerryBlender_EventScript_TryLeadGroup
	case 2, BerryBlender_EventScript_CloseLink
	case MULTI_B_PRESSED, BerryBlender_EventScript_CloseLink
	end

BerryBlender_EventScript_TryLeadGroup:
	call BerryBlender_EventScript_TryBecomeLinkLeader
	compare VAR_RESULT, LINKUP_SUCCESS
	goto_if_eq BerryBlender_EventScript_LinkLeaderDecided
	compare VAR_RESULT, LINKUP_FAILED
	goto_if_eq BerryBlender_EventScript_DecideLinkLeader
	compare VAR_RESULT, LINKUP_RETRY_ROLE_ASSIGN
	goto_if_eq BerryBlender_EventScript_TryLeadGroup
	release
	end

BerryBlender_EventScript_TryJoinGroup:
	call BerryBlender_EventScript_TryJoinLinkGroup
	compare VAR_RESULT, LINKUP_SUCCESS
	goto_if_eq BerryBlender_EventScript_LinkLeaderDecided
	compare VAR_RESULT, LINKUP_FAILED
	goto_if_eq BerryBlender_EventScript_DecideLinkLeader
	compare VAR_RESULT, LINKUP_RETRY_ROLE_ASSIGN
	goto_if_eq BerryBlender_EventScript_TryJoinGroup
	release
	end

BerryBlender_EventScript_TryBecomeLinkLeader:
	special TryBecomeLinkLeader
	waitstate
	return

BerryBlender_EventScript_TryJoinLinkGroup:
	special TryJoinLinkGroup
	waitstate
	return

BerryBlender_EventScript_LinkLeaderDecided:
	goto BerryBlender_EventScript_SpawnLinkPartners
	end
